<template>
    <el-form-item label="受众操作系统" prop="title">
        <div class="flexbox flexcenter checked_list">
            <el-radio label="1" v-model="dataForm.adgroup.audience[dataForm.audience_index].operating_all" @change="changeNull">
                <div class="checked_item"><img src="@/assets/img/market_checked.svg" alt="" class="conversion_check">不限</div>
            </el-radio>
            <el-checkbox-group v-model="dataForm.adgroup.audience[dataForm.audience_index].operating_systems" @change="changeAgeHas">
                <el-checkbox label="ANDROID">
                    <div class="checked_item"><img src="@/assets/img/market_checked.svg" alt="" class="conversion_check">安卓</div>
                </el-checkbox>
                <el-checkbox label="IOS">
                    <div class="checked_item"><img src="@/assets/img/market_checked.svg" alt="" class="conversion_check">苹果</div>
                </el-checkbox>
            </el-checkbox-group>
        </div>
    </el-form-item>
</template>

<script>
export default {
    props:["dataForm"],
    name: "",
    data() {
        return {};
    },
    created() {
        for(let i in this.dataForm.adgroup.audience){
            if(this.dataForm.adgroup.audience[i].operating_systems==undefined){
                this.$set(this.dataForm.adgroup.audience[i], "operating_systems", [])
            }
            if(this.dataForm.adgroup.audience[i].operating_all==undefined){
                this.$set(this.dataForm.adgroup.audience[i], "operating_all", "1")
            }
        }
    },
    computed:{
        
    },
    methods: {
        //不限选择
        changeNull() {
            this.dataForm.adgroup.audience[this.dataForm.audience_index].operating_systems = [];
            this.sessionSave();
        },
        changeAgeHas() {
            if (this.dataForm.adgroup.audience[this.dataForm.audience_index].operating_systems.length == 0) {
                this.dataForm.adgroup.audience[this.dataForm.audience_index].operating_all= "1";
            } else {
                this.dataForm.adgroup.audience[this.dataForm.audience_index].operating_all = "";
            }
            this.sessionSave();
        },

        sessionSave(){
            this.$emit("sessionSave")
        }
    },
    components: {},
};
</script>


<style scoped>
</style>

